<template>
  <div class="todo-footer">
    <label>
      <!--已经完成事件与总事情个数相等,复选框应该勾选上-->
      <input
        type="checkbox"
        :checked="todoIsDone.length === todos.length && todos.length > 0"
        @change="handler"
      />
    </label>
    <span
      ><span>已完成{{ todoIsDone.length }}</span> / 全部{{ todos.length }}
    </span>
    <button class="btn btn-danger" @click="deleteTodoIsDone">清除已完成任务</button>
  </div>
</template>

<script>
export default {
  name: "",
  props: ["todos", "todoIsDone", "updateAllTodoDone","deleteTodoIsDone"],
  methods: {
    handler(event) {
      //获取当前复选框的勾选状态 event.target获取到input标签DOM节点,打点checked属性,获取到input标签勾选状态[真:true,假:false]
      let done = event.target.checked;
      //调用父亲的方法,通知父组件修改全部的数据
      this.updateAllTodoDone(done);
    },
  },
};
</script>

<style scoped>
</style>
